﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class admin_login : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Label1.Text = new randomCode().RandomNum(4);   //产生验证码
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strUser = this.TextBox1.Text.ToString().Trim();
        string strPwd = this.TextBox2.Text.ToString().Trim();
        Md5Pw md5 = new Md5Pw();

        if (string.IsNullOrEmpty(strUser))
        {
            Response.Write("<script>alert('用户名不能为空！');</script>");
        }
        else if (string.IsNullOrEmpty(strPwd))
        {
            Response.Write("<script>alert('密码不能为空！');</script>");
        }
        else
        {
            //删除验证码
            //if (string.IsNullOrEmpty(TextBox3.Text) || TextBox3.Text.Trim().ToLower() != Label1.Text.ToLower())
            //{
            //    Response.Write("<script language=javascript>alert('验证码不正确！');</script>");
            //    return;
            //}

            int AdminType = AdminCs.Admin_Login(strUser, md5.Md5(strPwd));
            if (AdminType > -1)
            {
                Session["Wn_Admin"] = strUser;
                Session["AdminType"] = AdminType;
                Response.Redirect("frame/Main.aspx");
            }
            else
            {
                Response.Write("<script language=javascript>alert('用户名、密码有错误！');</script>");
            }
        }
    }
}
